// OpenGL.h
//
#ifndef OPENGL_ONCE
#define OPENGL_ONCE

#if 1
#include <GL/glew.h> // include glew.h BEFORE any other gl includes
#else
#define GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX          0x9047
#define GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX    0x9048
#define GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX  0x9049
#define GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX            0x904A
#define GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX            0x904B
#endif

// Standard opengl headers
#include <windows.h>
#include <GL/gl.h>
#include <GL/glu.h>

#include <vector>
#include <string>


namespace OpenGL{

#ifndef NDEBUG
	#define glCheck			OpenGL::glCheckError(__FILE__, __LINE__)
	#define glValidate		glGetError() == 0
#else
	#define glCheck
	#define glValidate      true
#endif

extern std::vector<std::string> glExtensions;

bool glInitExtensions();
void glCheckError(const char* file, unsigned line);
bool glSupportMemoryQuery();
int  glGetFreeMemory();
int  glGetTotalMemory();
int  glGetDedicatedTotalMemory();

#ifdef _USE_GLEW_
//extern GLEWContext *globalGlewContext;
//extern GLEWContext *startingContext;
#endif

}

#ifdef _USE_GLEW_
//inline GLEWContext *glewGetContext()		 { return OpenGL::globalGlewContext;}
//inline void glewSetContext(GLEWContext *ctx) { OpenGL::globalGlewContext = ctx ? ctx : OpenGL::startingContext;}
#endif

#endif
